package com.webbdong.aop.agent.test.bytebuddy;

import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @program: spring-agent
 * @description:
 * @author: zt22328 赵儒定
 * @create: 2023-03-31 15:08
 **/
public class BytebuddyVisitBase {

    protected String className;
    protected Class<?> adviceInterceptor;
    protected List<MethodDefinition> methods;

    public String getClassName() {
        return className;
    }

    public void setClassName(String className) {
        this.className = className;
    }

    public Class<?> getAdviceInterceptor() {
        return adviceInterceptor;
    }

    public void setAdviceInterceptor(Class<?> adviceInterceptor) {
        this.adviceInterceptor = adviceInterceptor;
    }

    public String[] getMethodNames() {
        if (this.methods == null) {
            return new String[0];
        }
        return methods.stream().map(MethodDefinition::getName)
                .collect(Collectors.toList()).toArray(new String[this.methods.size()]);
    }

    public List<MethodDefinition> getMethods() {
        return methods;
    }

    public void setMethods(List<MethodDefinition> methods) {
        this.methods = methods;
    }

    public static class MethodDefinition2 {

        private String name;

        private List<String> paramTypes;

        private boolean allMethods;

        public MethodDefinition2() {
        }
    }

    public static class MethodDefinition {

        private String name;

        private List<String> paramTypes;

        private boolean allMethods;

        public MethodDefinition() {
        }

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

        public List<String> getParamTypes() {
            return paramTypes;
        }

        public void setParamTypes(List<String> paramTypes) {
            this.paramTypes = paramTypes;
        }

        public boolean isAllMethods() {
            return allMethods;
        }

        public void setAllMethods(boolean allMethods) {
            this.allMethods = allMethods;
        }
    }
}
